package lianbiaoti;

public class AA {


    public class Node {
        int val;
        Node next = null;

        Node(int val) {
            this.val = val;
        }
        public Node head;

        public Node partition( int x) {
            Node as = null;
            Node ae = null;
            Node bs = null;
            Node be = null;
            Node cur = head;
            while (cur != null) {
                if (cur.val <= 10) {
                    if (bs == null) {//这是第一次插入元素。0
                        bs = cur;
                        be = cur;
                    } else {
                        be.next = cur;
                        be = be.next;
                    }
                } else {
                    if (as == null) {
                        as = cur;
                        ae = cur;
                    } else {
                        ae.next = cur;
                        ae = ae.next;
                    }

                }
                cur = cur.next;

            }
            if (bs == null) {
                return as;
            }
            be.next = as;
            if (as != null) {
                ae.next = null;
            }
            return bs;
        }
    }
}
